package com.google.code.lf.gfm.ui.error;

import java.util.logging.Level;

import org.eclipse.core.runtime.IStatus;

//TODO javadoc
public class StatusHelper {
	public static String toString(final int statusSeverity) {
		switch (statusSeverity) {
		case IStatus.OK:
			return "OK";
		case IStatus.INFO:
			return "INFO";
		case IStatus.WARNING:
			return "WARNING";
		case IStatus.ERROR:
			return "ERROR";
		default:
			throw new IllegalStateException("Unsupported severity : " + statusSeverity);
		}
	}

	public static String getText(final int statusSeverity) {
		switch (statusSeverity) {
		case IStatus.OK:
			return "OK";
		case IStatus.INFO:
			return "INFO";
		case IStatus.WARNING:
			return "WARNING";
		case IStatus.ERROR:
			return "ERROR";
		default:
			throw new ClientException("Unsupported severity : " + statusSeverity);
		}
	}

	/**
	 * Convertit la sévérité du statut spécifiée en son équivalent Log4j.
	 * 
	 * @param statusSeverity a sévirité du statut
	 * @return Le {@link Level} correspondant
	 */
	public static Level toLogLevel(final int statusSeverity) {
		Level level = null;
		switch (statusSeverity) {
		case IStatus.ERROR:
			level = Level.SEVERE;
			break;
		case IStatus.INFO:
			level = Level.INFO;
			break;
		case IStatus.OK:
			level = Level.FINEST;
			break;
		case IStatus.CANCEL:
		case IStatus.WARNING:
			level = Level.WARNING;
			break;
		default:
			level = Level.FINE;
			break;
		}
		return level;
	}

}
